package com.ww.learn.collection

fun main() {
    val sites = mapOf("pragprog" to "https://www.pragprog.com", "agiledeveloper" to "https://agiledeveloper.com")
    println(sites.size)

    println(sites.containsKey("agiledeveloper"))
    println(sites.containsValue("http://www.example.com"))
    println(sites.contains("agiledeveloper"))
    println("agiledeveloper" in sites)

    val pragProgSite: String? = sites.get("pragprog")

    val agiledeveloper = sites.getOrDefault("agiledeveloper", "http://www.example.com")

    // +运算符
    val sitesWithExample = sites + ("example" to "http://www.example.com")

    // -运算符
    val withoutAgileDeveloper = sites - "agiledeveloper"

    // 遍历
    for (entry in sites) {
        println("${entry.key} --- ${entry.value}")
    }

    for ((key, value) in sites) {

    }
}